const http = require('http')
const hostname = '127.0.0.1';
const port = 3030;
const server = http.createServer((req, res) => {
    res.statusCode = 200
    res.setHeader('Content-Type', 'application/json') //若产生乱码，请参考http协议，修订这里
        // res.end('你好世界\n') //加上utf-8不乱码
    var myObj = {
        name: "handsomeboy",
        job: "programmer",
        age: 99
    }
    res.end(JSON.stringify(myObj))
})

server.listen(port, hostname, () => {
    console.log(`服务器运行在 http://${hostname}:${port}/`); //注意这里的模板字符
})